package com.yenlien.traceyun.control.dao;


import com.yenlien.traceyun.control.entity.FruitTown;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface FruitTownDao extends BaseJpaDao<FruitTown> {


    @Transactional
    @Modifying
    @Query(value = "DELETE FROM t_fruit_town WHERE parent_id = ?1 OR id = ?1", nativeQuery = true)
    Integer delByParentId(String parentId);



    List<FruitTown> findByParentId(String parentId);


    @Query(value = "SELECT * FROM t_fruit_town WHERE `name` = ?1 AND type = ?2", nativeQuery = true)
    List<FruitTown> findByNameType(String name, String type);


    List<FruitTown> findByNameAndAnnual(String name, String annual);




    List<FruitTown> findByType(String type);





}
